/*
 * 回车复制
 *
 * @file   code-auto-save.js
 * @author codehui
 * @date   2018-10-27
 * @link   https://www.codehui.net
 */
(function() {

    const factory = function (exports) {
        // 定义插件名称
        var pluginName   = "code-enter";

        // 缓存key
      //  var cacheKey = 'editormd_cache';
        // 编辑器内容缓存key 替换url中的符号
      //  var cacheContentKey = ( location.protocol + location.host + location.pathname + location.search ).replace( /[.:?=\/-]/g, '_' );
        // 定义全局变量
        var cm;

        exports.fn.CodeEnter = function() {
            // 初始化系统变量
            var _this       = this;
            cm              = _this.cm;
            var settings    = _this.settings;
            var classPrefix = _this.classPrefix;
            var id          = _this.id;   // 编辑器id

            // 定时器
            var _saveFlag = null;
            // 自动保存间隔时间， 单位ms
            var saveInterval = 500;


            console.log('测试ok');

            // 注册change事件
            cm.on('keypress', function(e){
                var e = window.event ? window.event : e;
                var keyCode = e.which ? e.which : e.keyCode;
                if(keycode == 9 ){
                    alert(123);
                }
            })

        };




    };

    // CommonJS/Node.js
    if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
    {
        module.exports = factory;
    }
    else if (typeof define === "function")  // AMD/CMD/Sea.js
    {
        if (define.amd) { // for Require.js

            define(["editormd"], function(editormd) {
                factory(editormd);
            });

        } else { // for Sea.js
            define(function(require) {
                var editormd = require("./../../editormd");
                factory(editormd);
            });
        }
    }
    else
    {
        factory(window.editormd);
    }

})();

